﻿<ad:DockableContent
    x:Class="WPFToolboxForSiemensPLCs.DockableWindows.DockableContentBlockList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"
             mc:Ignorable="d" d:DesignHeight="339" d:DesignWidth="482" ad:ResizingPanel.ResizeWidth="400"
             GotFocus="DockableContent_GotFocus">
    <ad:DockableContent.Resources>
        <ContextMenu x:Key="cellContextMenu">
            <MenuItem x:Name="menuCreateAwl" Header="Create AWL" Click="menuCreateAwl_Click" />
        </ContextMenu>
        <Style TargetType="{x:Type DataGridCell}">
            <Setter Property="ContextMenu" Value="{DynamicResource cellContextMenu}" />
        </Style>
    </ad:DockableContent.Resources>


        <DataGrid AutoGenerateColumns="False" Name="myDataGrid" CanUserResizeRows="False" CanUserSortColumns="True"
              AlternatingRowBackground="Gainsboro"  AlternationCount="2" MouseDoubleClick="myDataGrid_MouseDoubleClick" CanUserAddRows="False" PreviewMouseDown="myDataGrid_PreviewMouseDown" PreviewMouseMove="myDataGrid_PreviewMouseMove" AllowDrop="False" GiveFeedback="myDataGrid_GiveFeedback" MouseDown="myDataGrid_MouseDown" SelectionChanged="myDataGrid_SelectionChanged">
            
        <DataGrid.Columns>
            <DataGridTemplateColumn Header="ObjectName" Width="Auto" IsReadOnly="True" SortMemberPath="ObjectName">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding BlockName}" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn Header="Symbol" Width="Auto" IsReadOnly="True" SortMemberPath="Symbol">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding SymbolTabelEntry.Symbol}" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn Header="Name" Width="Auto" IsReadOnly="True" SortMemberPath="Name">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Name}" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn Header="Type" Width="Auto" IsReadOnly="True" SortMemberPath="BlockTypeString">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding BlockTypeString}" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn Header="KnowHow" Width="Auto" IsReadOnly="True" SortMemberPath="KnowHowProtection">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding KnowHowProtection}" />
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
        </DataGrid.Columns> 
        <DataGrid.GroupStyle>
            <GroupStyle>
                <GroupStyle.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding Path=Name}" />
                        </StackPanel>
                    </DataTemplate>
                </GroupStyle.HeaderTemplate>
                <GroupStyle.ContainerStyle>
                    <Style TargetType="{x:Type GroupItem}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type GroupItem}">
                                    <Expander>
                                        <Expander.Header>
                                            <StackPanel Orientation="Horizontal">
                                                <TextBlock Text="{Binding Path=Name}" />
                                                <TextBlock Text=" ("/>
                                                <TextBlock Text="{Binding Path=ItemCount}"/>
                                                <TextBlock Text=" Items)"/>
                                            </StackPanel>
                                        </Expander.Header>
                                        <ItemsPresenter />
                                    </Expander>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </GroupStyle.ContainerStyle>
            </GroupStyle>
        </DataGrid.GroupStyle>
    </DataGrid>

</ad:DockableContent>
